package com.badibadi.activity;

import java.util.HashMap;
import java.util.Map;

import com.badibadi.infos.Results;
import com.badibadi.infos.UserInfoModel;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.Utils;
import com.badibadi.uniclubber.BastActivity;

import android.os.Bundle;

public class CommonActivity extends BastActivity {

	public static UserInfoModel InfoModel;

	private String uid;

	private boolean isRun = true;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		uid = Utils.getUid(CommonActivity.this);
		if (uid != null && !uid.equals("")) {
			putUidPost(uid);
		}
	}

	@Override
	protected void onStart() {
		super.onStart();
		isRun = true;
	}

	protected void putUidPost(final String uid) {
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				while (isRun) {

					try {
						Map<String, Object> map = new HashMap<String, Object>();
						map.put("uid", uid);
						String content = Utils.sendRequest(map,
								Constants.BadiUrl_1 + "user/loginStatus");
						Results results = Utils.checkResult_NNN(
								CommonActivity.this, content);
						if (results != null) {
							if (results.getRetmsg() != null && results.isRet()) {
							}
						}
						Thread.sleep(5 * 60 * 1000);
					} catch (Exception e) {
						   
					}
				}
			}
		});
	}
	
	@Override
	protected void onStop() {
		isRun = false;
		super.onStop();
	}
}
